#ifndef UNDISTORT_OPENCV_UNDISTORT_H
#define UNDISTORT_OPENCV_UNDISTORT_H

#include <regex>

#include "spdlog/spdlog.h"
#include "yaml-cpp/yaml.h"

#include "opencv2/opencv.hpp"

#include "util.h"

namespace casia {

    class OpencvUnDistort {
    private:
        /**
         * 原始图片
         */
        cv::Mat image;

        /**
         * 畸变矫正后图片
         */
        cv::Mat unDistortImage;

        /**
         * 相机内参矩阵
         */
        cv::Mat intrinsicMatrix = cv::Mat::eye(3, 3, CV_64F);

        /**
         * 相机畸变系数 [k1, k2, p1, p2, k3]
         * p1, p2, k3一般为 0
         */
        cv::Mat distortionMatrix = cv::Mat::zeros(5, 1, CV_64F);

    public:

        OpencvUnDistort();

        explicit OpencvUnDistort(const std::string& parameterFilePath);

        ~OpencvUnDistort();

        bool loadImage(const std::string& path);

        void showOriginImage();

        void showUnDistortImage();

        void UnDistort();

        void saveUnDistort(const std::string& path);

    };

}
#endif //UNDISTORT_OPENCV_UNDISTORT_H
